package me.keiwu.admin.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import me.keiwu.admin.rpc.RobotRpc;
import me.keiwu.admin.util.bean.AuthorityConst;
import me.keiwu.pub.data.ResponseV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


/**
 * Created by kei on 11/01/2018.
 */
@RestController
@RequestMapping("/api/robot")
public class RobotController {


    @Autowired
    private RobotRpc robotRpc;

    @PreAuthorize("hasAuthority('" + AuthorityConst.SUPER_ADMIN + "')")
    @RequestMapping("/loginAndCommit")
    @ResponseBody
    public ResponseV2 loginAndCommit(String loginData, String stepData) {
        JSONObject json = JSON.parseObject(robotRpc.loginAndCommit(loginData, stepData));
        return ResponseV2.ok(json);
    }

}
